/**
 * \class CDiscoveryProxy
 * \brief This is a proxy to discover available services in the cube cluster.
 * \version 0.3.2
 *
 * \author Woo-Hyun Kim (woorung@nhncorp.com, woorung@gmail.com)
 * \author http://blog.naver.com/wisereign .
 *
 * \date 2007/10/9
 */
#ifndef CDiscoveryProxyH
#define CDiscoveryProxyH
//-----------------------------------------------------------------
#include <iostream>

#include "common_discovery.h"
#include "service/CServiceRepository.h"
#include "service/CServiceProxy.h"

using namespace std;

class CDiscoveryProxy
{
private:
	string discovery_ip;
	int discovery_port;
	CServiceProxy *discovery_proxy;

	vector<CServiceInfo> services_info;

protected:
	void initialize();
	void finalize();

	int connect();

public:
        CDiscoveryProxy();
        CDiscoveryProxy(char *host, int port);
        virtual ~CDiscoveryProxy();

	struct soap *soap();

	int bind(char *host, int port);

	int advertise(CServiceRepository *repository, int ttl);

	vector<CServiceInfo> &discover(CServiceInfo *key);

	int invoke(cube__CService *serviceid, cube__CObject *in, struct cube__invokeResponse &res);
};
//-----------------------------------------------------------------
#endif
